<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
		/*for*/
			var arr=["java","数据库","C语言","C++","图形"];
			for(var i=0;i<arr.length;i++){
				console.log(arr[i]);
			}
		/*(for)遍历提取满18岁的Person*/
			function Person(name,age){
				this.name=name;
				this.age=age;
			}
			Person.prototype.toString=function(){
				return "Person[name="+this.name+",age="+this.age+"]";
			};	
			var per1=new Person("张三",18);
			var per2=new Person("李四",2);
			var per3=new Person("张是",9);
			var per4=new Person("李伞",31);
			
			var perArr=[per1,per2,per3,per4];
			console.log(perArr);
			
			console.log("满18岁的：");
			function getAdult(arr){
				var arr2=[];
				for(var i=0;i<arr.length;i++){
					if(arr[i].age>=18){
						arr2.push(arr[i]);
					}
				}
				return arr2;
			}
			var result=getAdult(perArr);
			console.log(result);
		/*forEach遍历*/
			arr=["java","数据库","C语言","C++","图形"];
			arr.forEach(function(value,index,obj){
				console.log(value);
				console.log(index);
			});
			
		</script>
	</head>
	<body>
	</body>
</html>
